//
//  SEChatButton.swift
//  SmartEyeForPatient
//
//  Created by QDSG on 2021/4/8.
//

import UIKit

class SEChatButton: UIButton {
    var showTextKeyboard: Bool
    
    required init?(coder: NSCoder) {
        self.showTextKeyboard = true
        super.init(coder: coder)
    }

}

extension UIButton {
    /// 控制声音按钮和键盘的图标切换
    /// - Parameter showKeyboard: 是否显示键盘
    func replaceVoiceButtonUI(showKeyboard: Bool) {
        if showKeyboard {
            setImage(Asset.btnChatKeyboard.image, for: UIControl.State())
            setImage(Asset.btnChatKeyboard.image, for: .highlighted)
        } else {
            setImage(Asset.btnChatVoice.image, for: UIControl.State())
            setImage(Asset.btnChatVoice.image, for: .highlighted)
        }
    }
    
    func replaceRecordButtonUI(isRecording: Bool) {
        if isRecording {
            setBackgroundImage(Asset.main.color.image(), for: .normal)
            setBackgroundImage(Asset.chatRecordBgNormal.color.image(), for: .highlighted)
        } else {
            setBackgroundImage(Asset.chatRecordBgNormal.color.image(), for: .normal)
            setBackgroundImage(Asset.main.color.image(), for: .highlighted)
        }
    }
}
